home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / FILE.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  2KB  |  72 lines

  1. /*
  2.  * Wrapper functions for accessing the file_struct fd array.
  3.  */
  4.  
  5. #ifndef __LINUX_FILE_H
  6. #define __LINUX_FILE_H
  7.  
  8. extern void __fput(struct file *);
  9.  
  10. /*
  11.  * Check whether the specified task has the fd open. Since the task
  12.  * may not have a files_struct, we must test for p->files != NULL.
  13.  */
  14. extern inline struct file * fcheck_task(struct task_struct *p, unsigned int fd)
  15. {
  16.     struct file * file = NULL;
  17.  
  18.     if (p->files && fd < p->files->max_fds)
  19.         file = p->files->fd[fd];
  20.     return file;
  21. }
  22.  
  23. /*
  24.  * Check whether the specified fd has an open file.
  25.  */
  26. extern inline struct file * fcheck(unsigned int fd)
  27. {
  28.     struct file * file = NULL;
  29.  
  30.     if (fd < current->files->max_fds)
  31.         file = current->files->fd[fd];
  32.     return file;
  33. }
  34.  
  35. extern inline struct file * fget(unsigned int fd)
  36. {
  37.     struct file * file = fcheck(fd);
  38.  
  39.     if (file)
  40.         file->f_count++;
  41.     return file;
  42. }
  43.  
  44. /*
  45.  * Install a file pointer in the fd array.
  46.  */
  47. extern inline void fd_install(unsigned int fd, struct file *file)
  48. {
  49.     current->files->fd[fd] = file;
  50. }
  51.  
  52. /*
  53.  * 23/12/1998 Marcin Dalecki <dalecki@cs.net.pl>: 
  54.  * 
  55.  * Since those functions where calling other functions, it was compleatly 
  56.  * bogous to make them all "extern inline".
  57.  *
  58.  * The removal of this pseudo optimization saved me scandaleous:
  59.  *
  60.  *         3756 (i386 arch) 
  61.  *
  62.  * precious bytes from my kernel, even without counting all the code compiled
  63.  * as module!
  64.  *
  65.  * I suspect there are many other similar "optimizations" across the
  66.  * kernel...
  67.  */
  68. extern void fput(struct file *file); 
  69. extern void put_filp(struct file *file);
  70.  
  71. #endif
  72.